//
//  ICTest.m
//  Charles
//
//  Created by Charles on 2017/6/30.
//  Copyright © 2017年 charles. All rights reserved.
//

#import "ICTest.h"
#import "IteratorObjects.h"
#import "CompositeProtocal.h"
#import "CompositeObjects.h"
@implementation ICTest

+ (void)testIterator {
    PancakeHouseMenu *pancakeHouseMenu = [[PancakeHouseMenu alloc]init];
    DinerMenu *dinerMenu = [[DinerMenu alloc]init];
    CafeMenu *cafeMenu = [[CafeMenu alloc]init];
    
    Waitress *waitress = [[Waitress alloc]initWithHouseMenu:pancakeHouseMenu dinerMenu:dinerMenu cafeMenu:cafeMenu];
    [waitress printMenu];

    NSLog(@"\n");
    
    NSArray *menus = @[pancakeHouseMenu,dinerMenu,cafeMenu];
    Waitress2 *waitress2 = [[Waitress2 alloc]initWithMenus:menus];
    [waitress2 printMenu];
}

+ (void)testComposite {
    
    //先把菜单添加进去
    id<MenuComponent> pancakeHouseMenu = [[CMenu alloc]initWithName:@"PANCAKE HOUSE MENU" desc:@"Breakfast"];
    id<MenuComponent> dinerMenu = [[CMenu alloc]initWithName:@"DINER MENU" desc:@"Lunch"];
    id<MenuComponent> cafeMenu = [[CMenu alloc]initWithName:@"CAFE MENU" desc:@"Diner"];
    id<MenuComponent> dessertMenu = [[CMenu alloc]initWithName:@"DISSERT MENU" desc:@"Dessert of course!"];
    
    id<MenuComponent> allMenus = [[CMenu alloc]initWithName:@"ALL MENUS" desc:@"All menus combined"];
    [allMenus addComponent:pancakeHouseMenu];
    [allMenus addComponent:dinerMenu];
    [allMenus addComponent:cafeMenu];
    
    [pancakeHouseMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"K&B's Pancake Breakfast" desc:@"Pancakes with scrabled eggs, and toast" vegetarian:NO price:2.99]];
    [pancakeHouseMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Regular Pancake Breakfast" desc:@"Pancakes with fried eggs, sausage" vegetarian:NO price:2.99]];
    [pancakeHouseMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Blueberry Pancake" desc:@"Pancakes made with fresh blueberries" vegetarian:NO price:2.99]];
    [pancakeHouseMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Waffles" desc:@"Waffles, with your choice of blueberries or strawberries" vegetarian:NO price:2.99]];

    [dinerMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Vegetarian BLT" desc:@"(Fakin‘) Bacon with lettuce & tomator on whole wheat" vegetarian:YES price:2.99]];
    [dinerMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"BLT" desc:@"Bacon with lettuce & tomator on whole wheat" vegetarian:NO price:2.99]];
    [dinerMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Soup of the day" desc:@"Soup of the day, with a side of potato salad" vegetarian:NO price:3.29]];
    [dinerMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Hotdog" desc:@"A hot dog, with saurkrant,relish,onions,topped with cheese" vegetarian:NO price:3.05]];
    
    [dinerMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Pasta" desc:@"Spaghetti with Marinara Sauce, and a slice of sourdough bread" vegetarian:YES price:3.89]];
    //dinerMenu 子菜单
    [dinerMenu addComponent:dessertMenu];
    [dessertMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc] initWithName:@"Apple pie" desc:@"Apple pie with a flakey crust, topped with vanilla ice cream" vegetarian:YES price:1.59]];
    
    [cafeMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Veggie Burger and Air Fries" desc:@"(Fakin‘) Bacon with lettuce & tomator on whole wheat" vegetarian:YES price:2.99]];
    [cafeMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"BLT" desc:@"Bacon with lettuce & tomator on whole wheat" vegetarian:NO price:2.99]];
    [cafeMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Soup of the day" desc:@"Soup of the day, with a side of potato salad" vegetarian:NO price:3.29]];
    [cafeMenu addComponent:(id<MenuComponent>)[[CMenuItem alloc]initWithName:@"Hotdog" desc:@"A hot dog, with saurkrant,relish,onions,topped with cheese" vegetarian:NO price:3.05]];
    
    CWaitress *waitress = [[CWaitress alloc]initWithAllMenus:allMenus];
    [waitress printMenu];
    [waitress printVegetarianMenu];

}

@end
